package com.bootdo.market.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.bootdo.common.utils.RedisUtils;
import com.bootdo.market.dao.CommonDao;
import com.bootdo.market.domain.ChannelDO;
import com.bootdo.market.domain.ChannelProfitDO;
import com.bootdo.market.service.AacommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
public class AaccommonServiceImpl implements AacommonService {
    @Autowired
    private CommonDao commonDao;
    @Resource
    private RedisUtils redisUtils;
    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public ChannelDO getChannelNameByChannelid(String id) {
        return commonDao.getChannelNameByChannelid(id);
    }

    @Override
    public List<Map<String, Object>> SdkListByChannelid(String channelid) {
        return commonDao.SdkListByChannelid(channelid);
    }

    @Override
    public List<ChannelProfitDO> exportChannelData(Map<String, Object> params) {
        return commonDao.exportChannelData(params);
    }


    @Override
    public List<Map<String, Object>> findNeizhi(Map<String, Object> params) {
        return commonDao.findNeizhi(params);
    }

    @Override
    public List<Map<String, Object>> findRegengNormal(Map<String, Object> params) {
        return commonDao.findRegengNormal(params);
    }

    @Override
    public List<Map<String, Object>> findRegengDelete(Map<String, Object> params) {
        return commonDao.findRegengDelete(params);
    }

    @Override
    public void saveRedis(Map<String, Object> params, Map<String, Object> mapData) {
        redisTemplate.opsForValue().set(params.get("channelid").toString() + params.get("sdkid"), JSONObject.toJSON(mapData).toString());
       /* String aa = redisTemplate.opsForValue().get(params.get("channelid").toString() + params.get("sdkid")).toString();
        String aaaa = JSONObject.toJSON(aa).toString();
        System.out.println(aaaa);*/
    }

    @Override
    public List<Map<String, Object>> tagListByProductid(Integer productid) {
        return commonDao.tagListByProductid(productid);
    }
}
